var app = getApp();
var $ = require("../../utils/httpHelper.js")
var wxParse = require("../../wxParse/wxParse.js")
Page({

  /**
   * 页面的初始数据
   */
  data: {
    channellist: [],
    classinfo:'',
    height: 0,
    currentTab: 0,
    iszhangjie:false,
    class_id:''
  },
  onShareAppMessage: function (res) {
    let member_id = app.globalData.userInfo.member_id
    return {
      title: '牛邵教育',
      path: '/pages/index/index?inviter_id=' + member_id,
      success: function (res) {
        // 转发成功
      },
      fail: function (res) {
        // 转发失败
      }
    }
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var self = this;
    wx.getSystemInfo({
      success: function (res) {
        console.log(res);
        self.setData({ height: res.windowHeight })
      }
    })
    if(options.id){
      let params = {
        rd_session: app.globalData.userInfo.rd_session,
        id: options.id
      }
      $.httpPost("class_detail", params, (data, err) => {
        this.setData({
          channellist: data.data.channel_list,
          classinfo: data.data.class_info,
          class_id: options.id
        })
        wxParse.wxParse("about", "html", data.data.class_info.content, this)
      })
    }

  },
  
  clicktab(e) {
    let tab = e.currentTarget.dataset.tab
    let types = e.currentTarget.dataset.status
    if (this.data.currentTab != tab) {
      this.setData({
        currentTab: tab,
      })
    }
    if(tab == 0){
      this.setData({
        iszhangjie:false
      })
    }else{
      this.setData({
        iszhangjie: true
      })
    }
  },
  pay(){
    wx.navigateTo({
      url: '/pages/obligation/obl_class?id='+this.data.class_id
    })
  }
})